﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WebClass
{
    public class LabelingOperation
    {
        ResearchDBDataContext researchDB;
        public LabelingOperation()
        {
            researchDB = new ResearchDBDataContext();
        }
        public void Cal()
        {
            var rankResult = from exp in researchDB.tb_experiments
                             from query in exp.tb_experimentsQueries
                             where query.rank != -1
                             group query by new {query.tb_experiment.newsID , query.query ,query.rank }into g
                             select g;
            foreach (var item in rankResult)
            {
                Console.WriteLine(item.Key.query);
                if (item.Key.rank == 0)
                {
                    Console.WriteLine("rank 0");
                    foreach (var i in item)
                    {
                        Console.WriteLine(i.tb_experiment.tb_user.name);
                    }
                }
                else if (item.Key.rank == 1)
                {
                    Console.WriteLine("rank 1");
                    foreach (var i in item)
                    {
                        int userID = (int)i.tb_experiment.userID;
                        Console.WriteLine(i.tb_experiment.tb_user.name);
                    }
                }
                else if (item.Key.rank == 2)
                {
                    Console.WriteLine("rank 2");
                    foreach (var i in item)
                    {
                        int userID = (int)i.tb_experiment.userID;
                        Console.WriteLine(i.tb_experiment.tb_user.name);
                    }
                }
            }
        }
    }
}
